# Use an official OpenJDK 8 runtime as a parent image
FROM openjdk:17-jdk-alpine
# FROM openjdk:17-jdk-slim
# FROM openjdk:17
# FROM bitnami/java:17

# Set the working directory in the container
WORKDIR /app

# Copy the executable JAR file to the container
COPY target/backend.jar /app/app.jar

# COPY --from=docker.elastic.co/observability/apm-agent-java:1.25.0 /usr/agent/elastic-apm-agent.jar /elastic-apm-agent.jar
COPY --from=docker.elastic.co/observability/apm-agent-java:1.29.0 /usr/agent/elastic-apm-agent.jar /elastic-apm-agent.jar

# Expose the port the application runs on
EXPOSE 5603
EXPOSE 15603

# Run the JAR file
# -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=15603
ENTRYPOINT ["sh", "-c", "exec java $JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=15603 -Dname=backend.jar -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -jar /app/app.jar"]
